package cn.wzy.controller;

import cn.wzy.dto.LoginDTO;
import cn.wzy.results.ResponseResult;
import cn.wzy.service.LoginService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController
@RequestMapping("/login")
public class LoginController {

    @Resource
    public LoginService loginService;

    /*
    * 登入
    * */
    @PostMapping("/account")
    public ResponseResult login(@RequestBody LoginDTO loginDTO){
        return loginService.loginAccount(loginDTO);
    }
    /*
    * 手机登入
    * */
    @PostMapping("/phone")
    public ResponseResult loginPhone(@RequestBody LoginDTO loginDTO){
        return loginService.loginPhone(loginDTO);
    }

    /*
    * wx登入
    * */
    @PostMapping("/wechat")
    public ResponseResult loginWechat(@RequestBody Map<String,String> wechat){
        return loginService.loginWechat(wechat);
    }
    /*
    * 退出登入
    * */
    @GetMapping("/loginOut")
    public ResponseResult loginOut(HttpServletRequest request){
        return loginService.loginOut(request);
    }
}
